package com.example.mobile2030606155byl0506class19work;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView textView;
    private EditText editTxtMainUsername;
    private EditText editTxtMainPassword;
    private Button btnMainLogin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainLogin.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,ShowActivity.class);
                //第一种方式
                intent.putExtra("userName",editTxtMainUsername.getText().toString().trim());
                //第二种方式
                Bundle bundle = new Bundle();
                bundle.putString("passWord",editTxtMainPassword.getText().toString().trim());
                intent.putExtras(bundle);
                startActivity(intent);
            }
        });
    }

    private void initView() {
        textView = findViewById(R.id.textView);
        editTxtMainUsername = findViewById(R.id.editTxtMainUsername);
        editTxtMainPassword = findViewById(R.id.editTxtMainPassword);
        btnMainLogin = findViewById(R.id.btnMainLogin);
    }
}